package com.travel.recommend.controller;

import java.util.Arrays;
import java.util.Map;

import com.travel.common.to.AttractionInfoTo;
import com.travel.common.to.UpdateUserTagWeightTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.travel.recommend.entity.UserTagWeightEntity;
import com.travel.recommend.service.UserTagWeightService;
import com.travel.common.utils.PageUtils;
import com.travel.common.utils.R;



/**
 * 
 *
 * @author lxw
 * @email lxw@gmail.com
 * @date 2024-01-24 16:13:13
 */
@RestController
@RequestMapping("recommend/usertagweight")
public class UserTagWeightController {
    @Autowired
    private UserTagWeightService userTagWeightService;


    /**
     * 更新用户对景点标签的权重
     */
    @RequestMapping("/updateUserTagWeight/{userId}")
    public R updateUserTagWeight(@RequestBody UpdateUserTagWeightTo to, @PathVariable("userId")Integer userId){
        userTagWeightService.updateUserTagWeight(to,userId);

        return R.ok();
    }


    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("recommend:usertagweight:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userTagWeightService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{userTagWeightId}")
    //@RequiresPermissions("recommend:usertagweight:info")
    public R info(@PathVariable("userTagWeightId") Integer userTagWeightId){
		UserTagWeightEntity userTagWeight = userTagWeightService.getById(userTagWeightId);

        return R.ok().put("userTagWeight", userTagWeight);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("recommend:usertagweight:save")
    public R save(@RequestBody UserTagWeightEntity userTagWeight){
		userTagWeightService.save(userTagWeight);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("recommend:usertagweight:update")
    public R update(@RequestBody UserTagWeightEntity userTagWeight){
		userTagWeightService.updateById(userTagWeight);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("recommend:usertagweight:delete")
    public R delete(@RequestBody Integer[] userTagWeightIds){
		userTagWeightService.removeByIds(Arrays.asList(userTagWeightIds));

        return R.ok();
    }

}
